home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / codeli_1 / setup.exe / _SETUP.1 / frmMenusWithRadioButtons.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-07-21  |  3.7 KB  |  115 lines

  1. VERSION 5.00
  2. Begin VB.Form frmMenusWithRadioButtons 
  3.    Caption         =   "Menus With Radio Buttons"
  4.    ClientHeight    =   2880
  5.    ClientLeft      =   165
  6.    ClientTop       =   735
  7.    ClientWidth     =   5130
  8.    Icon            =   "frmMenusWithRadioButtons.frx":0000
  9.    LinkTopic       =   "Form1"
  10.    PaletteMode     =   1  'UseZOrder
  11.    ScaleHeight     =   2880
  12.    ScaleWidth      =   5130
  13.    StartUpPosition =   3  'Windows Default
  14.    Begin VB.Label Label1 
  15.       Alignment       =   1  'Right Justify
  16.       AutoSize        =   -1  'True
  17.       Caption         =   "Written for the VB Center Code Library"
  18.       BeginProperty Font 
  19.          Name            =   "Small Fonts"
  20.          Size            =   6.75
  21.          Charset         =   0
  22.          Weight          =   400
  23.          Underline       =   0   'False
  24.          Italic          =   0   'False
  25.          Strikethrough   =   0   'False
  26.       EndProperty
  27.       Height          =   165
  28.       Left            =   2700
  29.       TabIndex        =   1
  30.       Top             =   2400
  31.       Width           =   2355
  32.    End
  33.    Begin VB.Label Label2 
  34.       Alignment       =   1  'Right Justify
  35.       AutoSize        =   -1  'True
  36.       Caption         =   "http://www.geocities.com/SiliconValley/Way/6445"
  37.       BeginProperty Font 
  38.          Name            =   "MS Sans Serif"
  39.          Size            =   8.25
  40.          Charset         =   0
  41.          Weight          =   700
  42.          Underline       =   0   'False
  43.          Italic          =   0   'False
  44.          Strikethrough   =   0   'False
  45.       EndProperty
  46.       ForeColor       =   &H00800000&
  47.       Height          =   195
  48.       Left            =   720
  49.       TabIndex        =   0
  50.       Top             =   2640
  51.       Width           =   4365
  52.    End
  53.    Begin VB.Menu Options 
  54.       Caption         =   "Options"
  55.       Begin VB.Menu mnuOptions 
  56.          Caption         =   "Option Radio Item 1"
  57.          Index           =   0
  58.       End
  59.       Begin VB.Menu mnuOptions 
  60.          Caption         =   "Option Radio Item 2"
  61.          Index           =   1
  62.       End
  63.       Begin VB.Menu mnuOptions 
  64.          Caption         =   "Option Radio Item 3"
  65.          Index           =   2
  66.       End
  67.       Begin VB.Menu mnuOptions 
  68.          Caption         =   "-"
  69.          Index           =   3
  70.       End
  71.       Begin VB.Menu mnuOptions 
  72.          Caption         =   "Option Check Item 1"
  73.          Index           =   4
  74.       End
  75.       Begin VB.Menu mnuOptions 
  76.          Caption         =   "Option Check Item 2"
  77.          Index           =   5
  78.       End
  79.       Begin VB.Menu mnuOptions 
  80.          Caption         =   "Option Check Item 3"
  81.          Index           =   6
  82.       End
  83.    End
  84. Attribute VB_Name = "frmMenusWithRadioButtons"
  85. Attribute VB_GlobalNameSpace = False
  86. Attribute VB_Creatable = False
  87. Attribute VB_PredeclaredId = True
  88. Attribute VB_Exposed = False
  89. Private Sub Form_Load()
  90. ' just change the radio check for the first 3 menu items
  91. SetRadioMenuChecks mnuOptions(0), 0
  92. SetRadioMenuChecks mnuOptions(1), 1
  93. SetRadioMenuChecks mnuOptions(2), 2
  94. End Sub
  95. Private Sub SetRadioMenuChecks(Mnu As Menu, ByVal mnuItem&)
  96. Dim hMenu&
  97. Dim mInfo As MENUITEMINFO
  98. ' get the menu item handle
  99. hMenu& = GetSubMenu(GetMenu(Mnu.Parent.hwnd), 0)
  100. ' copy it's attributes to the new Type,
  101. ' changing the checkmark to a radio button
  102. mInfo.cbSize = Len(mInfo)
  103. mInfo.fType = MFT_RADIOCHECK
  104. mInfo.fMask = MIIM_TYPE
  105. mInfo.dwTypeData = Mnu.Caption & Chr$(0)
  106. ' change the menu checkmark
  107. SetMenuItemInfo hMenu&, mnuItem&, 1, mInfo
  108. End Sub
  109. Private Sub mnuOptions_Click(Index As Integer)
  110. Static prevSelection As Integer
  111. mnuOptions(prevSelection).Checked = False
  112. mnuOptions(Index).Checked = True
  113. prevSelection = Index
  114. End Sub
  115.